import java.util.Scanner;

import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    static int mod = 998244353;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt(), T = sc.nextInt();

        long[][] b = new long[n][m];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                b[i][j] = 1;
            }
        }
        long[][]a = new long[n][m];

        for (int t = 1; t <= T; t++) {
            if (t % 2 == 0) {
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < m; j++) {
                        if (a[i][j] == 1) b[i][j] = 0;
                    }
                }

                for (int i = 0; i < n; i++) {
                    Arrays.fill(a[i], 0);
                }


                long[][] tmp = new long [n][m];

                int[]dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};

                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < m; j++) {
                        if (b[i][j] > 0) {
                            for (int d = 0; d < 4; d++) {
                                int ni = i + dx[d], nj = j + dy[d];
                                if (ni >= 0 && ni < n && nj >= 0 && nj < m) {
                                    tmp[ni][nj] = (tmp[ni][nj] + b[i][j]) % mod;
                                }
                            }
                        }
                    }

                }

            }



            if (sc.hasNext()) {
                int op = sc.nextInt();
                if (op == 1) {
                    if (sc.hasNextInt()) {
                        int x = sc.nextInt() - 1, y = sc.nextInt() - 1;
                        if (sc.hasNextInt()) {
                            int h = sc.nextInt();
                            b[x][y] = h;
                        }
                    }
                }
                else {
                    if (sc.hasNextInt()) {
                        int x = sc.nextInt() - 1, y = sc.nextInt() - 1;
                        a[x][y] = 1;
                        b[x][y] = 0;
                    }
                }
            }


            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    System.out.print(b[i][j] + " ");
                }
                System.out.println();
            }
            System.out.println();

        }



        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                System.out.print(b[i][j] + " ");
            }
            System.out.println();
        }
    }

}